import React from 'react'
import PropTypes from 'prop-types'
import ListItemText from '@material-ui/core/ListItemText';
import ListItem from '@material-ui/core/ListItem'

/**
 * 文本列表
 */
class TextOnlyListItem extends React.Component {
    state = {
        selectedIndex: 1,
    };

    handleListItemClick = (event, index) => {
        this.setState({ selectedIndex: index });
    };

    render() {
        const {primary, secondary, inset, isSelectedItem, ...other } = this.props

        if(isSelectedItem === true) {
            return (
                <ListItem {...other} selected={this.state.selectedIndex === 0}
                          onClick={event => this.handleListItemClick(event, 0)}>
                    <ListItemText primary={primary} secondary={secondary} inset={inset}/>
                </ListItem>
            )
        }else {
            return (
                <ListItem {...other}>
                    <ListItemText primary={primary} secondary={secondary} inset={inset}/>
                </ListItem>
            )
        }
    }
}
TextOnlyListItem.propTypes = {
    primary: PropTypes.string.isRequired,
    secondary: PropTypes.string,
    dense: PropTypes.bool,
    classes: PropTypes.object,
    button:PropTypes.bool,
    component:PropTypes.string,
    href:PropTypes.string
}

export default TextOnlyListItem